package erz.printing.police;

import android.content.Intent;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;

public class XunWenActivity extends BaseActivity implements View.OnClickListener {

    private View diandongcheEntry;
    private View rushidaoqieEntry;
    private View huichaiEntry;
    private View chebeihuaEntry;
    private View darenEntry;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_xun_wen);

        ActionBar actionBar = getSupportActionBar();
        actionBar.setDisplayHomeAsUpEnabled(true);

        initView();
        initRightDutyPrint();
    }

    @Override
    public boolean onSupportNavigateUp() {
        finish();
        return true;
    }

    private void initView() {
        diandongcheEntry = findViewById(R.id.diandongche_entry);
        rushidaoqieEntry = findViewById(R.id.rushidaoqie_entry);
        huichaiEntry = findViewById(R.id.huichai_entry);
        chebeihuaEntry = findViewById(R.id.huache_entry);
        darenEntry = findViewById(R.id.oudaren_entry);

        diandongcheEntry.setOnClickListener(this);
        rushidaoqieEntry.setOnClickListener(this);
        huichaiEntry.setOnClickListener(this);
        chebeihuaEntry.setOnClickListener(this);
        darenEntry.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        int id = view.getId();
        if (id == R.id.diandongche_entry) {
            Intent intent = new Intent(this, PrintPhotoActivity.class);
            Bundle bundle = new Bundle();
            bundle.putString("checkTitle", "电动车被盗");
            bundle.putString("docTemplateNotice", "pdf/被盗自行车摩托车受害人询问笔录.pdf");
            bundle.putString("noticeName", "受害人询问笔录");
            bundle.putString("title", "盗窃电动车");
            bundle.putBoolean("printTitle", true);
            intent.putExtras(bundle);
            startActivity(intent);
        }
        else if (id == R.id.rushidaoqie_entry) {
            Intent intent = new Intent(this, PrintPhotoActivity.class);
            Bundle bundle = new Bundle();
            bundle.putString("checkTitle", "被入室盗窃");
            bundle.putString("docTemplateNotice", "pdf/入室盗窃受害人询问笔录.pdf");
            bundle.putString("noticeName", "受害人询问笔录");
            bundle.putString("title", "入室盗窃");
            bundle.putBoolean("printTitle", true);
            intent.putExtras(bundle);
            startActivity(intent);
        }
        else if (id == R.id.huichai_entry) {
            Intent intent = new Intent(this, PrintPhotoActivity.class);
            Bundle bundle = new Bundle();
            bundle.putString("checkTitle", "财物被毁");
            bundle.putString("docTemplateNotice", "pdf/毁财案件受害人询问笔录.pdf");
            bundle.putString("noticeName", "受害人询问笔录");
            bundle.putString("title", "普通毁财");
            bundle.putBoolean("printTitle", true);
            intent.putExtras(bundle);
            startActivity(intent);
        }
        else if (id == R.id.huache_entry) {
            Intent intent = new Intent(this, PrintPhotoActivity.class);
            Bundle bundle = new Bundle();
            bundle.putString("checkTitle", "汽车被划");
            bundle.putString("docTemplateNotice", "pdf/毁财案件受害人询问笔录.pdf");
            bundle.putString("noticeName", "受害人询问笔录");
            bundle.putString("title", "汽车被划");
            bundle.putBoolean("printTitle", true);
            intent.putExtras(bundle);
            startActivity(intent);
        }
        else if (id == R.id.oudaren_entry) {
            Intent intent = new Intent(this, PrintPhotoActivity.class);
            Bundle bundle = new Bundle();
            bundle.putString("checkTitle", "被殴打");
            bundle.putString("docTemplateNotice", "pdf/殴打他人案件受害人询问笔录.pdf");
            bundle.putString("noticeName", "受害人询问笔录");
            bundle.putString("title", "殴打他人");
            bundle.putBoolean("printTitle", true);
            intent.putExtras(bundle);
            startActivity(intent);
        }
    }

    private void startDocumentActivity(String docTemplate, String title) {
        Intent newIntent = new Intent(this, DocumentActivity.class);
        Bundle newBundle = new Bundle();

        newBundle.putString("docTemplate", docTemplate);
        newBundle.putString("title", title);

        newIntent.putExtras(newBundle);
        startActivity(newIntent);
    }

    private void initRightDutyPrint() {
        findViewById(R.id.bei_hai_ren).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startDocumentActivity("pdf/被害人权利义务告知书.pdf", "被害人权利义务告知书");
            }
        });
        findViewById(R.id.bei_hai_ren_su_song).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startDocumentActivity("pdf/被害人诉讼权利义务告知书.pdf", "被害人诉讼权利义务告知书");
            }
        });
        findViewById(R.id.xiang_zheng_an_jian).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startDocumentActivity("pdf/行政案件权利义务告知书.pdf", "行政案件权利义务告知书");
            }
        });
        findViewById(R.id.zheng_ren_su_song).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startDocumentActivity("pdf/证人诉讼权利义务告知书.pdf", "证人诉讼权利义务告知书");
            }
        });
    }
}
